package com.study.xml.controller;

import com.study.xml.common.utils.XmlUtils;
import com.study.xml.model.CreateInvoiceBO;
import com.study.xml.model.PartialOrder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Admin
 * @since 2021-11-21
 */
@RestController
@RequestMapping("/test")
public class TestController {

    @PostMapping("/parseFromXml")
    public PartialOrder parseFromXml(@RequestBody String xml) {
        return XmlUtils.parseFromXml(xml, PartialOrder.class);
    }

    @PostMapping("/parseFromXml2")
    public CreateInvoiceBO parseFromXml2(@RequestBody String xml) {
        return XmlUtils.parseFromXml(xml, CreateInvoiceBO.class);
    }

    @PostMapping("/toXml")
    public String toXml(@RequestBody CreateInvoiceBO invoiceBO){
        return XmlUtils.toXml(invoiceBO);
    }

}
